System and method for generating Enterprise Java Bean code

ABSTRACT

A system and method for generating code for an Enterprise Java Bean comprising generating at least one output based on a description of at least one Enterprise Java Bean, wherein the description is attended by at least one annotation. A system and method for generating an annotated description of an Enterprise Java Bean based on at least one input, wherein the description can be used to generate the at least one input.

CROSS REFERENCES

[0001] The following related documents are hereby incorporated byreference in their entirety: BEAWEBLOGIC SERVER®: ASSEMBLING ANDCONFIGURING WEB APPLICATIONS (Release 7.0, Jun. 28, 2002); BEAWEBLOGICSERVER®: PROGRAMMING WEBLOGIC ENTERPRISE JAVABEANS (Release 7.0, Jun.28, 2002); BEAWEBLOGIC SERVER®: DEVELOPING WEBLOGIC SERVER APPLICATIONS(Release 7.0, Jun. 28, 2002); BEAWEBLOGIC SERVER®: WEBLOGIC BUILDERONLINE HELP (Release 7.0, Jun. 28, 2002); BEAWEBLOGIC SERVER®:PROGRAMMING WEBLOGIC XML (Release 7.0, Jun. 28, 2002); BEAWEBLOGICSERVER®: PROGRAMMING WEBLOGIC WEB SERVICES (Release 7.0, Jun. 28, 2002);BEAWebLogic Server®: Programming WebLogic Enterprise JavaBeans (Release7.0, Jun. 28, 2002).

COPYRIGHT NOTICE

[0002] A portion of the disclosure of this patent document containsmaterial which is subject to copyright protection. The copyright ownerhas no objection to the facsimile reproduction by anyone of the patentdocument or the patent disclosure, as it appears in the Patent andTrademark Office patent file or records, but otherwise reserves allcopyright rights whatsoever.

FIELD OF THE DISCLOSURE

[0003] The present invention disclosure relates to the field ofautomatic code generation, in particular, automatic generation ofEnterprise Java™ Bean source code files from an annotated classdefinition and the reverse.

BACKGROUND

[0004] Enterprise Java™ Beans are reusable software components writtenin the Java™ programming language. An Enterprise Java™ Bean (EJB) istypically declared in a number of separate source files which definevarious aspects of the EJB, such as its class, interfaces and deploymentbehavior. Each time a modification is made to one EJB source file, theother associated EJB source files must also be modified accordingly.This activity is cumbersome and error prone, since the changes must bemanually propagated to different files. What is needed is a way togenerate source files for EJB's with minimal editing and duplication ofinformation.

BRIEF DESCRIPTION OF THE DRAWINGS

[0005]FIG. 1 is a block diagram of an EJB code generation system inaccordance to one embodiment of the invention.

[0006]FIG. 2 is a block diagram of a reverse EJB code generation systemin accordance to one embodiment of the invention.

DETAILED DESCRIPTION

[0007] The invention is illustrated by way of example and not by way oflimitation in the figures of the accompanying drawings in which likereferences indicate similar elements. It should be noted that referencesto “an” or “one” embodiment in this disclosure are not necessarily tothe same embodiment, and such references mean at least one.

[0008] In one embodiment, instead of having to edit and maintain severalEJB files for each EJB (e.g., the bean class, remote and home classes,deployment descriptors, etc.), editing is limited to a single file thatcontains an annotated description of one or more EJB class definitions.EJB's are declared in the Java™ programming language. The Java™programming language and run-time environment are available from SunMicrosystems, Inc., of Palo Alto, Calif. The annotated description fileis processed in accordance to one embodiment and the EJB files requiredfor deployment on a server are automatically generated. Annotations aredirectives that contain information needed to create an EJB's sourcefiles. In one embodiment, annotations are interspersed between Java™source code statements. In another embodiment, annotations are embeddedin Java™ comments. In yet another embodiment, an annotation is a Javadoctag. Javadoc is the tool for generating source code documentation inhypertext markup language (“HTML”) format from tags embedded in Java™source code comments. Javadoc is available from Sun Microsystems, Inc.In another embodiment, annotations are provided separately from thedescription of one or more EJB classes. For example, annotations can beprovided in a graphical user interface, a separate file, or createddynamically based on run-time properties a user has associated with anEJB.

[0009] In one embodiment, by way of example, annotations can take theform: @ejbgen-name [attribute[=expression]] . . .attribute[=expression]], where items in square brackets are optionalarguments. Name can be the type of annotation and the optionalattribute=expression list can be comprised of one or moreattribute-expression pairs. In one embodiment, attribute is the name ofa required or optional parameter associated with an annotation and theoptional expression can be, for example, an infix, postfix or prefixexpression that evaluates to a constant (e.g., a number or analpha-numeric string). In another embodiment, an expression's operatorscan be arithmetic, logical and string-based. For example, the followingJava™ code segment has a comment block that contains three annotations:/**  * @ejbgen:cmp-field column = acct_id  * @ejbgen:primkey-field  *@ejbgen:remote-method transaction-attribute = Required  */ abstractpublic String getAccountId( );

[0010] Conventionally, an EJB's abstract accessor methods definecontainer-managed persistence (“CMP”) data fields of the same name. Forexample, in the code segment above, assuming the accessor methodgetAccountId( ) was an EJB method, a corresponding data field called“accountId” would be defined upon deployment of the EJB. In oneembodiment, the annotation “@ejbgen:cmp-field” specifies that theAccountld CMP field will be stored in column named “acct_id” of adatabase upon deployment of the EJB. The annotation“@ejbgen:primkey-field” indicates that Accountld will be a primary keyin the database. Finally, the annotation “@ejbgen:remote-method”specifies that transaction isolation is required for the methodgetAccountId( ). All three annotations can be considered methodannotations since they come before the declaration of a method.

[0011]FIG. 1 is a block diagram in accordance to one embodiment of theinvention. An annotated description 1 is processed by analyzer 2.Annotated description 1 can include one or more EJB definitions. In oneembodiment, annotated description 1 can reside in a computer file. Inanother embodiment, annotated description 1 can reside in a computermemory. In yet a further embodiment, annotated description 1 can betransmitted via a computer network (not shown) to analyzer 2. Analyzer 2employs parser 4 to divide the Java™ source text in annotateddescription 1 into discrete units and extract annotations therefrom.Analyzer 2 may perform preprocessing of annotated description 1 beforemaking use of parser 4. In one embodiment, parser 4 can exploit thedoclet application programming interface available in Javadoc. TheJavadoc doclet interface provides programmatic access to a parsedrepresentation of a Java™ source file. In one embodiment, parser 4 canprocess the entire annotated description 1 at once. In anotherembodiment, parser 4 can be employed repeatedly by analyzer 2 toincrementally process annotated description 1. Each annotation isverified by comparing what was found in the annotated description 1 witha formal definition in annotation library 5. In one embodiment, by wayof example, annotation library 5 can be a database that includes thedefinition of each annotation (e.g., its required and optionalparameters, permissible values, etc.). In another embodiment, annotationlibrary 5 can be implemented as a cache, tree or any other suitable datastructure without departing from the spirit or scope of the presentdisclosure.

[0012] If the annotation and its arguments are proper, analyzer 2evaluates any attribute-expression arguments provided. The can be doneduring the validation of each annotation, or in another embodiment,after all annotations have been verified. Values for variable names thatoccur in expressions are retrieved from variable library 6. In oneembodiment, variable library 6 can be implemented in a similar fashionto annotation library 5. In a further embodiment, variable names can beconstructed dynamically from expressions using string concatenationoperators. In one embodiment, each attribute-expression is evaluated,comparing the value of the expression to permissible values allowed fora given attribute as dictated by annotation library 5. If anexpression's value is out of range or erroneous, an error can bedeclared. In another embodiment, a suitable default value can beprovided in place of the errant expression. The form of expressions canbe, for example, infix, postfix and prefix. Means for parsing andevaluating such expressions are well known in the art. Based on theparsed annotations, code generator 3 emits the classes or files 7necessary to deploy the EJB(s) described in annotated description 1.

[0013] In one embodiment, annotations can be described in terms of theirattributes, their scope (e.g., class or method) and the type of EJB theyare applicable to (e.g., message, stateless session, stateful session,entity, etc.). Annotations having class scope come before a classdeclaration and annotations having method scope come before a methoddeclaration. Annotations can also be adjacent to or associated withother Java™ elements such as fields or variables. In a furtherembodiment, and by way of illustration, annotations can be defined as inthe following tables. The Annotation/Attribute column contains theannotation name in the first row of each table and any associatedattribute names in the subsequent rows. The Description column containsa description of the annotation or attribute. The For column indicateswhether the annotation is applicable to a class or a method. Finally,the EJB Type column indicates the type of EJB the annotation isapplicable to (e.g., session, message, entity, etc.). It will beapparent to those skilled in the art that many such annotations arepossible and therefore this illustration is illustrative and should notbe construed to be limiting in any respect. EJB Annotation/AttributeDescription For Type @ejbgen:automatic-key- Automatically generatedatabase keys for new Class Entity generation entity objects. cache-sizeThe size of the key cache. (Required) Name The name of the keygenerator. (Required) Type The type of the key generator. (Required)@ejbgen:cmp-field Specifies a container-managed field. Method EntityColumn The column where this CMP field will be mapped. (Required)column-type (OracleClob|OracleBlob) The type of this column. group-namesThe names of the groups this field belongs to, separated by commas.ordering-number (0..n) The number where this field must appear insignatures and constructors. For this ordering to work, all CMR and CMPfields must have this attribute to a distinct numeric value.@ejbgen:cmr-field Specifies a container-managed relationship. MethodEntity group-names The names of the groups this field belongs toseparated by commas. ordering-number (0..n) The number where this fieldmust appear in signatures and constructors. For this ordering to work,all CMR and CMP fields must have this attribute to a distinct numericvalue. @ejbgen:create-default- Automatically create required databasetables. Class Entity rdbms-tables @ejbgen:ejb-client-jar Specify thename of the jar file to generate. Class All file-name The name of theclient jar to generate. If more than one EJB's have this tag, only oneof the specified jar files will be included in the deploymentdescriptor. (Required) @ejbgen:ejb-local-ref Declare a reference to anEJB that is in the same Class All container and EJB JAR file. Home Logalclass of the bean. jndi-name The JNDI name of the reference. Link Linkof the bean. Local Home class of the bean. Name Name of the reference.Type (Entity|Session) @ejbgen:ejb-ref Define a reference to another EJBwithin the Class All Java ™ Naming and Directory Interface (“JNDI”)Environment Naming Context (“ENC”). Home Home class of the bean.jndi-name The JNDI name of the reference. Link Link of the bean. NameName of the reference. Remote Remote class of the bean. Type(Entity|Session) @ejbgen:entity Declare an entity bean. Class Entityejb-name The name of this Entity bean. (Required) prim-key-class TheJava ™ class of the primary key. In case of a compound primary key, thisclass will be generated. (Required) Sometimes, a simple (e.g.java.lang.String) primary key class will not be enough to identify anEJB uniquely. In such a case, a primary key is needed. A primary key isa custom Java class containing several fields. All of the fieldstogether identify an EJB uniquely. There are certain constraintsassociated with the compound primary key class (e.g it must beSerializable, implement hashCode( ), equals( ), etc.). A compoundprimary key class can contain fields that form a subset of the CMPfields of the EJB. In order to define a compound primary key class:Annotate each CMP field that should be part of the primary key classwith @primkey-field. abstract-schema-name The abstract schema name forthis EJB. If not specified, the ejb-name value will be used.cache-between- (True|False) Whether to cache the persistent datatransactions of an entity bean across (between) transactions.check-exists-on-method (True|False) Whether the container checks for theexistence of a bean for each method call. concurrency-strategy (ReadOnly|Exclusive|Database) Defines the concurrency strategy for this bean.data-source-name The name of the data source (as it was declared inconfig.xml). database-type The type of the database. db-is-shared(True|False) Whether the database is shared. default-transaction Thetransaction attribute to be applied to all methods that do not have amore specific transaction attribute setting. delay-database-insert- (ejbCreate|ejbPost Create) until delay-updates-until-end- (True|False)Whether updates will be sent after the of-tx transaction has committed.enable-dynamic-queries (True|False) Whether dynamic queries are enabled.finders-load-bean (True|False) If this is set to True, the beans willimmediately be loaded into the cache by the finder.home-call-router-class- Class to be used for routing home method calls.name home-is-clusterable (True|False) Whether this bean can be deployedfrom multiple servers in a cluster. home-load-algorithm(Round|Robin|Random|WeightBased) The algorithm to use for load-balancingbetween replicas of this home. idle-timeout-seconds Maximum duration anEJB should stay in the cache. invalidation-target The ejb-name of aread-only Entity bean that should be invalidated when this Container-Managed Persistence Entity EJB has been modified. max-beans-in-cache Themaximum number of beans in the cache. Optimistic-column The column thatholds the time stamp for optimistic concurrency persistence-type(cmp|bmp) The type of this Entity bean (default: cmp)prim-key-class-nogen (True|False). If this keyword is specified, EJBGenwill not generate the primary key class. read-timeout-seconds The numberof seconds between each ejbLoad( ) call on a Read-Only Entity bean.reentrant (True|False) Whether the class methods are reentrant. run-asSpecifies the role-name for this EJB. run-as identity-principal The nameof the principal in case the role maps to several principals. table-nameThe name of the table this Entity bean is mapped to.trans-timeout-seconds The transaction timeout (in seconds).use-caller-identity (True|False) Whether this EJB uses caller'sidentity. verify-columns (Read|Modified|Version|Timestamp) Howoptimistic concurrency verifies that the columns modified during thetransactions have not been modified. @ejbgen:env-entry Declare anenvironment entry to be made available Class All through JNDI ENC. NameThe name of this environment entry. (Required) Type The Java type forthis environment entry (must be fully qualified, even if java.lang).(Required) Value The value for this environment entry. (Required)@ejbgen:file-generation Control which files are generated. Class Alllocal-class (True|False) Whether to generate the local interface forthis EJB. local-home (True|False) Whether to generate the local homeinterface for this EJB. pk-class (True|False) Whether to generate theprimary key class for this EJB. remote-class (True|False) Whether togenerate the remote interface for this EJB. remote-home (True|False)Whether to generate the remote home interface for this EJB. value-class(True|False) Whether to generate the value class for this EJB@ejbgen:finder Specify finder method attributes. Class Entitycaching-name The name of an eager relationship caching. ejb-ql The EJBQL request as it will appear in the deployment descriptor. group-nameName of the group for the WebLogic query include-updates (True|False)Whether updates made during the current transaction must be reflected inthe result of a query. isolation-level The type of transaction isolationfor this method. max-elements The maximum number of elements that shouldbe returned by a multi-valued query. Signature It must match exactly thesignature generated on the Home class. sql-select-distinct (True|False)Whether the generated SQL ‘SELECT’ will contain a ‘DISTINCT’ qualifier.transaction-attribute The transaction attribute for this local method.If not specified, the default transaction attribute will be used.Methods with this tag will be generated on the Local class.Weblogic-ejb-ql The Weblogic EJB QL request as it will appear in thedeployment descriptor. @ejbgen:foreign jms- Specify the provider of aJava ™ Message Service Class Message- provider (“JMS”) Drivenconnection-factory-jndi- The connection factory JNDI name. (Required)name initial context-factory The initial JNDI context factory.(Required) provider-url The provider URL. (Required) @ejbgen:isolation-Specify transaction isolation level in the server. Class All levelpattern isolation-level The isolation level for the methods specified inthe pattern tag. (Required) Pattern The pattern that matches all methodsthat will receive this isolation level (e.g. “*”). (Required)@ejbgen:jndi-name Specify the JNDI name of this bean. Class All LocalThe local JNDI name of this EJB. If not specified, local interfaces willnot be generated. Remote The remote JNDI name of this EJB. If notspecified, remote interfaces will not be generated. @ejbgen:local-homeSpecify attributes of this local home method. Method Entity, methodSession Roles Comma-separated list of roles that are allowed to invokethis method. transaction-attribute The transaction attribute for thislocal method. If not specified, the default transaction attribute willbe used. Methods with this tag will be generated on the Local class.@ejbgen:local-method Specify attributes of this local method. MethodEntity, Session isolation-level The type of transaction isolation forthis method. Roles Comma-separated list of roles that are allowed toinvoke this method. transaction-attribute The transaction attribute forthis local method. If not specified, the default transaction attributewill be used. Methods with this tag will be generated on the Localclass. @ejbgen:message-driven Declare a message-driven EJB. ClassMessage- Driven destination-jndi-name The JNDI name of the destination.(Required) ejb-name The name of this Message-Driven bean. (Required)acknowledge-mode (auto-acknowledge-ok-acknowledge) The acknowledgementmode. default-transaction The transaction attribute to be applied to allmethods that do not have a more specific transaction attribute setting.destination-type (javax.jms.Queue|javax.jms.Topic).initial-beans-in-free-pool The initial number of beans in the free pool.max-beans-in-free-pool The maximum number of beans in the free pool.message-selector The JMS message selector. run-as Specifies therole-name for this EJB. run-as-identity-principal The name of theprincipal in case the role maps to several principals.trans-timeout-seconds The transaction timeout (in seconds).transaction-type (Bean|Container) Who manages the transactions for thisEJB. use-caller-identity (True|False) Whether this EJB uses caller'sidentity. @ejbgen:method- Specify a permission pattern for this class.Class All permission-pattern Pattern The pattern that matches allmethods that will receive this method permission (e.g. “*”). Roles Theroles for the methods specified in the pattern tag. Separated by acomma. @ejbgen:primkey-field Specify the primary key field for an entitybean. Method Entity @ejbgen:relation Specify an entity beanrelationship. Class Entity Unidirectional relationships are achieved byspecifying only the first three parameters (i.e, no cmr-field, nofk-column, no joint-table). multiplicity Many to many relationships mustspecify an extra table (“joint-table”) which must contain at least twocolumns. The names of these columns must match the names of the columnscontaining the foreign keys of the two EJB's being joined. (one|many)Specifies the multiplicity of the relationship. (Required) Name The nameof the relationship. Use the same name on both ends of a relationshipfor the roles to be generated properly (note that this constraintapplies to unidirectional as well). (Required) target-ejb The EJB nameof the target of this relationship. (Required) cascade-delete(True|False) cmr-field The CMR field where this relationship will bekept. If it not specified, the relationship is unidirectional. Ifspecified, the attribute fk-column must be specified as well.db-cascade-delete (True|False) Whether a cascade delete will use thebuilt-in cascade delete facilities of the underlying database. fk-columnOnly needed in a relationship having at least one side. In that case,the non-one side EJB must declare a column that it will use to store theprimary key of its counterpart. joint-table Only needed in a Many-Manyrelationship. It must be the name of an existing table that will be usedto hold the joint table containing the relationships. If using acompound primary key, specify a set of corresponding foreign keysseparated by commas. role-name The name of this role (such as“ParentHasChildren”). If no role name is given, will generate one.@ejbgen:relationship- Specify cache information for relationship. ClassEntity caching-element caching-name The name of an eager relationshipcashing. (Required) cmr-field The name of the CMR field. (Required)group-name The name of the group to be loaded for the CMR field.@ejbgen:remote-home- Specify roles allowed to invoke this home method.Method Entity, method Session The method name must start with “ejbHome”.Note: Home Methods do not apply to message EJB's Beans. The “throwsRemoteException” in the EJB class will be automatically generated in thehome class. Roles Comma-separated list of roles that are allowed toinvoke this method. transaction-attribute The transaction attribute forthis remote method. If not specified, the default transaction attributewill be used. Methods with this tag will be generated on the Remoteclass. @ejbgen:remote-method Specify a method available in a remoteinterface. Method Entity, Session isolation-level The type oftransaction isolation for this method. Roles Comma-separated list ofroles that are allowed to invoke this method. transaction-attribute Thetransaction attribute for this remote method. If not specified, thedefault transaction attribute will be used. Methods with this tag willbe generated on the Remote class. @ejbgen:resource- Specify the name ofa resource environment Class All env-ref reference. (Required) Name Nameof the resource environment reference. (Required) Type Type of theenvironment resource references (e.g. javax.jms.Queue). (Required)jndi-name JNDI name of the resource. @ejbgen:resource-ref Specify theJNDI name of a resource. Class All Auth (Application|Container)(Required) jndi-name JNDI name of the resource. (Required) Name Name ofthe resource. (Required) Type Tyoe of the resource (e.g.javax.sql.DataSource). (Required) sharing-scope (Shareable|Unshareable)@ejbgen:role-mapping Specify roles. Class All Principals The names ofthe principals in this role (separated by commas). (Required) role-nameThe name of the role. (Required) @ejbgen:select Specify attributes ofselect method. Method Entity ejb-ql The EJB-QL defining this selectmethod. Note: the method name must start with ejbSelect. (Required)caching-name The name of an eager relationship caching. group-name Nameof the group for the WebLogic query. include-updates (True|False)Whether updates made during the current transaction must be reflected inthe result of a query. max-elements The maximum number of elements thatshould be returned by a multi-valued query. result-type-mapping(Remote|Local) Whether the returned objects are mapped to EJBLocalObjector EJBObject. sql-select-distinct (True|False) Whether the generated SQL‘SELECT’ will contain a ‘DISTINCT’ qualifier. Weblogic-ejb-ql TheWeblogic EJB QL request as it will appear in the deployment descriptor.@ejbgen:session Declare a session bean. Class Session ejb-name The nameof this Session bean. (Required) bean-load-algorithm The algorithm touse for load-balancing between replicas of this bean.call-router-class-name Class name to be used for routing home methodcalls default-transaction The transaction attribute to be applied to allmethods that do not have a more specific transaction attribute setting.home-call-router-class- Class to be used for routing home method calls.name home-is-clusterable (True|False) Whether this bean can be deployedfrom multiple servers in a cluster. home-load-algorithm(RoundRobin|Random|WeightBased) The algorithm to use for load-balancingbetween replicas of this home. idle-timeout-seconds Maximum duration anEJB should stay in the cache initial-beans-in-free-pool The initialnumber of beans in the free pool. is-clusterable (True|False) Whetherthis bean is cluster-able. load-algorithm(RoundRobin|Random|WeightBased) The name of the algorithm used tobalance replicas of this home. max-beans-in-cache The maximum number ofbeans in the cache. max-beans-in-free-pool The maximum number of beansin the free pool. methods-are-idempotent (True|False) Whether themethods for this stateless session bean are idem potent or not.replication-type (InMemory|None) How to replicate stateful session beansin a cluster. run-as Specifies the role-name for this EJB.run-as-identity-principal The name of the principal in case the rolemaps to several principals. trans-timeout-seconds The transactiontimeout (in seconds). transaction-type (Bean|Counter) Who manages thetransactions for this EJB. Type (Stateless|Stateful) The type of theSession bean. If this attribute is not specified, EJBGen will guess theright type by looking at the ejbCreate( ) methods on the class.use-caller-identity (True|False) Whether this EJB uses caller'sidentity. @ejbgen:value-object Specify objects to be referenced by thevalue Class All object class. Reference (Local|Value) Specify whatobjects the value object class should reference when accessing otherEJB's. (Required)

[0014] In one embodiment, by way of example, the following classannotations accompany a Java™ code fragment that declares a statelesssession EJB “Trader” having a JNDI name of“ejb20-statelessSession-TraderHome”, and an environment variable“tradeLimit” with a default value of 500. /**  * @ejbgen:session  * ejb-name = statelessSession  *  max-beans-in-free-pool = 100  * is-clusterable = false  *  load-algorithm = Random  *  *@ejbgen:jndi-name  *  remote = ejb20-statelessSession-TraderHome  *  *@ejbgen:env-entry  *  name = tradeLimit  *  type = java.lang.Integer  * value = 500  *  */ public class TraderEJB implements SessionBean { private static final boolean VERBOSE = true;  private SessionContextctx;  private int tradeLimit;  ejbCreate( ); . . .

[0015] The type of session EJB (e.g., stateful or stateless) can beautomatically determined. For example, if there is an ejbCreate( )method having a non-empty parameter list, the EJB is stateful.Otherwise, the EJB is stateless. Two methods associated with this EJBare declared below with method annotations indicating that they areavailable through a remote interface (i.e., to clients residing outsideof the Java™ application server in which this EJB is deployed). Noticethat both methods make use of the environment variable “tradeLimit”which was declared in the class annotation.  /**   /**   *  Buys sharesof a stock for a named customer.   *   *  @ejbgen:remote-method   */ public TradeResult buy(String stockSymbol, int shares) {   if (shares >tradeLimit) {    log(“Attempt to buy “+shares+” is greater than limit of”+tradeLimit);    shares = tradeLimit;   }  log(“Buying “+shares+”shares of ”+stockSymbol);  return new TradeResult(shares, stockSymbol); }  /**   *  Sells shares of a stock for a named customer.   *   * @ejbgen:remote-method   *   */  public TradeResult sell(StringstockSymbol, int shares) {   if (shares > tradeLimit) {    log(“Attemptto sell “+shares+” is greater than limit of ”+tradeLimit);    shares =tradeLimit;   }   log(“Selling “+shares+” shares of ”+stockSymbol);  return new TradeResult(shares, stockSymbol);  } }

[0016] The @ejbgen:remote-method annotation indicates that a method willbe available in a remote interface. A remote interface declares an EJB'smethods that are accessible to applications outside of an EJB'scontainer. Two Java™ files and two deployment descriptors areautomatically generated in accordance to an embodiment based on the codefragment above: File Name Contents TraderHome importjavax.ejb.CreateException; .java import javax.ejb.EJBHome; importjavax.ejb.FinderException; import java.rmi.RemoteException; Home importjava.util.Collection; Interface public interface TraderHome extendsEJBHome {  public Trader create( )   throws CreateException,RemoteException, CreateException; } Trader.java importjava.rmi.RemoteException; import javax.ejb.EJBObject; Remote publicinterface Trader extends EJBObject { Interface  public TradeResultbuy(String stockSymbol, int shares)  throws RemoteException;   publicTradeResult sell (String stockSymbol, int shares)   throwsRemoteException; } ejb-jar.xml <ejb-jar>  <enterprise-beans>   <session>EJB    <ejb-name>statelessSession</ejb-name> Deployment<home>examples.ejb20.basic.statelessSession. Descriptor TraderHome</home> <remote>examples.ejb20.basic.statelessSession. Trader</remote>   <ejb- class>examples.ejb20.basic.statelessSession.TraderEJB</ejb-class>    <session-type>Stateless</session-type>   <transaction-type>Container</transaction-type>    <env-entry>    <env-entry-name>INTL</env-entry-name>    <env-entry-type>java.lang.Double</env-entry- type>    <env-entry-value>15.0</env-entry-value>    </env-entry>   <env-entry>     <env-entry-name>tradeLimit</env-entry-name>    <env-entry-type>java.lang.Integer</env-entry- type>    <env-entry-value>500</env-entry-value>    </env-entry>   <env-entry>     <env-entry-name>WEBL</env-entry-name>    <env-entry-type>java.lang.Double</env-entry- type>    <env-entry-value>10.0</env-entry-value>    </env-entry>   </session> </enterprise-beans> </ejb-jar> weblogic- <?xml version=“1.0”?>ejb-jar.xml <!DOCTYPE weblogic-ejb-jar PUBLIC “-//BEA Systems, Inc.//DTDWebLogic 6.0.0 EJB//EN”“http://www.bea.com/servers/wls600/dtd/weblogic-ejb- BEA jar.dtd” >WebLogic <weblogic-ejb-jar> Server ®  <weblogic-enterprise-bean>Deployment   <ejb-name>statelessSession</ejb-name> Descriptor  <stateless-session-descriptor>    <pool>    <max-beans-in-free-pool>100</max-beans-     in-free-pool>    </pool>   <stateless-clustering>     <stateless-bean-is-clusterable>false</stateless-bean-is-clusterable>   </stateless-clustering>   </stateless-session-descriptor>  <jndi-name>ejb20-statelessSession-TraderHome</jndi- name> </weblogic-enterprise-bean> </weblogic-ejb-jar>

[0017] In one embodiment, a value associated with an attribute can bespecified with a constant or a variable. In another embodiment, avariable definition can be separate from the EJB definition (e.g., inanother file). For example, the variable “remote-jndi-name” can bedefined as “Account” as follows:

[0018] remote-jndi-name=Account

[0019] Within the annotated description, variables can be accessed withthe delimiters “${“and”}”. For example:

[0020] @ejbgen:jndi-name

[0021] remote=${remote-jndi-name}

[0022] Thus, “remote” would be equal to “Account”.

[0023] In another embodiment, variables can be used anywhere after anannotation and can contain whole annotation definitions. Assuming thefollowing variable definition:

[0024] jndi-name-tag=remote=RemoteAccount local=LocalAccount

[0025] The following annotation:

[0026] @ejbgen:jndi-name

[0027] ${jndi-name-tag}

[0028] would expand to:

[0029] @ejbgen:jndi-name

[0030] remote=RemoteAccount Local=LocalAccount

[0031] In another embodiment, predefined variables are recognized.Predefined variables have default values that can be overridden. In oneembodiment, predefined variables can be defined as follows: VariableName Description remote.baseClass The value of this variable will beused as the base class for all generate remote classes. home.baseClassThe value of this variable will be used as the base class for allgenerated remote home classes. local.baseClass The value of thisvariable will be used as the base class for all generated local classes.localHome.baseClass The value of this variable will be used as the baseclass for all generated local home classes. value.baseClass The value ofthis variable will be used as the base class for all generated valueclasses. value.package The value of this variable will be used as thepackage for all generated value classes.

[0032] In another embodiment, predefined variables can be prefixed witha class name. For example, if the following predefined variables areoverridden as follows:

[0033] Account.home-baseClass=BaseAccountHome

[0034] home.baseClass=BaseHome

[0035] value.package=value

[0036] containerManaged.value.package=valuePackageForContainerManaged

[0037] Thus, all home interfaces generated will extend the classBaseHome except the home of EJB “Account”, which will extendBaseAccountHome.

[0038] In another embodiment, EJB annotations can be inherited accordingto Java™ class inheritance. For example, if an EJB named AccountEJB hasa base class BaseAccount: /**  *  @ejbgen:jndi-name  *   remote=“BaseRemote”  *  @ejbgen:entity  *   max-beans-in-cache = 300*/ public class BaseAccount implements EntityBean { . . . } /**  * @ejbgen:entity  *   ejb-name = containerManaged  *   table-name =ejbAccounts  *   data-source-name = examples-dataSource-demoPool  *  max-beans-in-cache = 400  * */ public class AccountEJB extendsBaseAccount { . . .

[0039] The JNDI remote name “BaseRemote” and max-beans-in-cache of 300that are defined in the class BaseAccount are inherited by the subclassAccountEJB. The subclass can optionally override these values. Forexample, the value of max-beans-in-cache is overridden to be 400 insteadof 300.

[0040] In another embodiment, EJB relations can be inherited if a valuefor the attribute ‘role-name’ is specified. All “role-name” attributesin the Java™ inheritance path can be merged. For example, the followingparent class defines a partial relation: /**  *  @ejbgen:relation  *  name = Many1-Many2  *   role-name = Many1HasMany2  *   multiplicity =many * role-name = Many1HasMany2  *   target-ejb = Many2EJB  *  fk-column = many2_fk  *   joint-table = join_table  */ abstract publicclass BaseMany1 extends BaseEntityBean {

[0041] The following subclass inherits the above relation and completesits definition:  *  @ejbgen:relation  *   role-name = Many1HasMany2  *  cmr-field = many2  *  */ abstract public class Many1EJB extendsBaseMany1 {

[0042] It will be apparent to those skilled in the art that the processof generating EJB source files from an annotated description of an EJBcan be performed in reverse. All of the files or classes needed todeploy an EJB can be reduced into a single annotated description of theEJB which can, in accordance to one embodiment, be used in turn toreproduce the EJB source files. Annotations can be generatedautomatically based information contained in the class definitions,deployment descriptors and relationships between classes.

[0043]FIG. 2 is a block diagram in accordance to one embodiment of theinvention. A plurality of input files 7 containing EJB classes anddeployment information is processed by analyzer 8. Input files 7 caninclude one or more EJB class definitions. In one embodiment, inputfiles 7 can reside in a single file, such as a Java™ Archive File(“JAR”). In another embodiment, input files 7 can reside in a computermemory. In yet a further embodiment, input files 7 can be transmittedvia a computer network (not shown) to analyzer 8. Analyzer 8 employsparser 10 to extract information related to class structure, classrelationships and deployment from input files 7. Analyzer 8 may performpreprocessing of input files 7 before making use of parser 10. In oneembodiment, parser 10 can exploit the doclet application programminginterface available in Javadoc. In one embodiment, parser 10 can processall input files 7 at once. In another embodiment, parser 10 can beemployed repeatedly by analyzer 8 to incrementally process input files7. During or after parsing, analyzer 8 builds an EJB database 11containing all of the extracted information pertaining to each EJBrepresented by input files 7. The EJB database 11 information is thenexamined to identify which annotation(s) from annotation library 5adequately describe the EJB'S. The these annotations (not shown) alongwith the EJB database 11 information are provided to code generator 9.Code generator 9 then emits annotated Java™ code 1 to describe the EJBclass(s) in input files 7.

[0044] The foregoing description of the preferred embodiments of thepresent invention has been provided for the purposes of illustration anddescription. It is not intended to be exhaustive or to limit theinvention to the precise forms disclosed. Many modifications andvariations will be apparent to the practitioner skilled in the art.Embodiments were chosen and described in order to best describe theprinciples of the invention and its practical application, therebyenabling others skilled in the art to understand the invention, thevarious embodiments and with various modifications that are suited tothe particular use contemplated. It is intended that the scope of theinvention be defined by the following claims and their equivalents.

What is claimed is:
 1. A method for generating Enterprise Java Beans,comprising: generating at least one output based on a description of atleast one Enterprise Java Bean (EJB), wherein the description isattended by at least one annotation and the at least one annotationincludes at least one variable. 2 The method of claim 1 wherein: the atleast one annotation can be inherited.
 3. The method of claim 1 wherein:the at least one output includes one of a local interface class, a homeinterface class, a remote interface class, and a deployment descriptor.4. The method of claim 1 wherein: the at least one EJB is one of anentity EJB, a stateful session EJB, a stateless session EJB, and amessage driven EJB.
 5. The method of claim 4 wherein: an entity EJBincludes at least one of the following relationships: one-to-one,one-to-many, many-to-many, unidirectional, and bi-directional.
 6. Themethod of claim 1 wherein: the at least one annotation includes at leastone attribute.
 7. The method of claim 6 wherein: the at least oneattribute is associated with at least one expression.
 8. The method ofclaim 2 wherein: annotation inheritance is based on Java classinheritance.
 9. The method of claim 1 wherein: the at least one variableis one of user-specified and predefined.
 10. The method of claim 9wherein: the at least one predefined variable can be redefined.
 11. Themethod of claim 9 wherein: the at least one predefined variable can beprefixed with a class name.
 12. The method of claim 1 wherein: the atleast one annotation is one of a class annotation and a methodannotation.
 13. The method of claim 1 wherein: the at least oneannotation is a Javadoc tag.
 14. The method of claim 1 wherein: the atleast one variable can be defined separately from the description of theat least one EJB.
 15. The method of claim 1 wherein: the at least oneoutput can be used to generate the description of the at least one EJB.16. A method for generating Enterprise Java Beans, comprising:generating at least one output based on a description of at least oneEnterprise Java Bean (EJB), wherein the description includes at leastone annotation and the at least one annotation can be inherited.
 17. Themethod of claim 16 wherein: the at least one output includes one of alocal interface class, a home interface class, a remote interface class,and a deployment descriptor.
 18. The method of claim 16 wherein: the atleast one EJB is one of an entity EJB, a stateful session EJB, astateless session EJB, and a message driven EJB.
 19. The method of claim18 wherein: an entity EJB includes at least one of the followingrelationships: one-to-one, one-to-many, many-to-many, unidirectional,and bi-directional.
 20. The method of claim 16 wherein: the at least oneannotation includes at least one attribute.
 21. The method of claim 20wherein: the at least one attribute is associated with at least oneexpression.
 22. The method of claim 16 wherein: annotation inheritanceis based on Java class inheritance.
 23. The method of claim 16 wherein:the at least one annotation includes at least one variable.
 24. Themethod of claim 23 wherein: the at least one variable is one ofuser-specified and predefined.
 25. The method of claim 24 wherein: theat least one predefined variable can be redefined.
 26. The method ofclaim 24 wherein: the at least one predefined variable can be prefixedwith a class name.
 27. The method of claim 16 wherein: the at least oneannotation is one of a class annotation and a method annotation.
 28. Themethod of claim 16 wherein: the at least one annotation is a Javadoctag.
 29. The method of claim 23 wherein: the at least one variable canbe defined separately from the description of the at least one EJB. 30.The method of claim 16 wherein: the at least one output can be used togenerate the description of the at least one EJB.
 31. A methodcomprising: generating a description of at least one Enterprise JavaBean (EJB) from at least one input, wherein the description includes atleast one annotation and the description can be used to generate the atleast one input.
 32. The method of claim 31 wherein: the at least oneannotation can be inherited.
 33. The method of claim 31 wherein: the atleast one input includes one of a local interface class, a homeinterface class, a remote interface class, and a deployment descriptor.34. The method of claim 31 wherein: the at least one EJB is one of anentity EJB, a stateful session EJB, a stateless session EJB, and amessage driven EJB.
 35. The method of claim 34 wherein: an entity EJBincludes at least one of the following relationships: one-to-one,one-to-many, many-to-many, unidirectional, and bi-directional.
 36. Themethod of claim 31 wherein: the at least one annotation includes atleast one attribute.
 37. The method of claim 36 wherein: the at leastone attribute is associated with at least one expression.
 38. The methodof claim 32 wherein: annotation inheritance is based on Java classinheritance.
 39. The method of claim 31 wherein: the at least oneannotation is one of a class annotation and a method annotation.
 40. Themethod of claim 31 wherein: the at least one annotation is a Javadoctag.
 41. A system for generating Enterprise Java Beans, comprising: ananalyzer to process a description of at least one Enterprise Java Beans(EJB); and a code generator coupled to the analyzer, the code generatorto generate at least one output; and wherein the description includes atleast one annotation and the at least one annotation includes at leastone variable.
 42. The system of claim 41 wherein: the analyzer includesat least one of a parser, a annotation library, and a variable library.43. The system of claim 41 wherein: the at least one annotation can beinherited.
 44. The system of claim 41 wherein: the at least one outputincludes one of a local interface class, a home interface class, aremote interface class, and a deployment descriptor.
 45. The system ofclaim 41 wherein: the at least one EJB is one of an entity EJB, astateful session EJB, a stateless session EJB, and a message driven EJB.46. The system of claim 45 wherein: an entity EJB includes at least oneof the following relationships: one-to-one, one-to-many, many-to-many,unidirectional, and bi-directional.
 47. The system of claim 41 wherein:the at least one annotation includes at least one attribute.
 48. Thesystem of claim 47 wherein: the at least one attribute is associatedwith at least one expression.
 49. The system of claim 43 wherein:annotation inheritance is based on Java class inheritance.
 50. Thesystem of claim 41 wherein: the at least one variable is one ofuser-specified and predefined.
 51. The system of claim 50 wherein: theat least one predefined variable can be redefined.
 52. The system ofclaim 50 wherein: the at least one predefined variable can be prefixedwith a class name.
 53. The system of claim 41 wherein: the at least oneannotation is one of a class annotation and a method annotation.
 54. Thesystem of claim 41 wherein: the at least one annotation is a Javadoctag.
 55. The system of claim 41 wherein: the at least one variable canbe defined separately from the description of the at least one EJB. 56.The system of claim 41 wherein: the at least one output can be used togenerate the description of the at least one EJB.
 57. A system forgenerating Enterprise Java Beans, comprising: an analyzer to process adescription of at least one Enterprise Java Beans (EJB); and a codegenerator coupled to the analyzer, the code generator to generate atleast one output; and wherein the description includes at least oneannotation and the at least one annotation can be inherited.
 58. Thesystem of claim 57 wherein: the analyzer includes at least one of aparser, a annotation library, and a variable library.
 59. The system ofclaim 57 wherein: the at least one annotation includes at least onevariable.
 60. The system of claim 57 wherein: the at least one outputincludes one of a local interface class, a home interface class, aremote interface class, and a deployment descriptor.
 61. The system ofclaim 57 wherein: the at least one EJB is one of an entity EJB, astateful session EJB, a stateless session EJB, and a message driven EJB.62. The system of claim 61 wherein: an entity EJB includes at least oneof the following relationships: one-to-one, one-to-many, many-to-many,unidirectional, and bi-directional.
 63. The system of claim 57 wherein:the at least one annotation includes at least one attribute.
 64. Thesystem of claim 63 wherein: the at least one attribute is associatedwith at least one expression.
 65. The system of claim 57 wherein:annotation inheritance is based on Java class inheritance.
 66. Thesystem of claim 59 wherein: the at least one variable is one ofuser-specified and predefined.
 67. The system of claim 66 wherein: theat least one predefined variable can be redefined.
 68. The system ofclaim 66 wherein: the at least one predefined variable can be prefixedwith a class name.
 69. The system of claim 57 wherein: the at least oneannotation is one of a class annotation and a method annotation.
 70. Thesystem of claim 57 wherein: the at least one annotation is a Javadoctag.
 71. The system of claim 59 wherein: the at least one variable canbe defined separately from the description of the at least one EJB. 72.The system of claim 57 wherein: the at least one output can be used togenerate the description of the at least one EJB.
 73. A system forgenerating an annotated description of an Enterprise Java Bean,comprising: an analyzer to process at least one input; and a codegenerator coupled to the analyzer, the code generator to generate adescription of at least one Enterprise Java Bean (EJB) from the at leastone input; and wherein the description includes at least one annotation;and wherein the description can be used to generate the at least oneinput.
 74. The system of claim 73 wherein: the analyzer includes atleast one of a parser, a annotation library, and a database.
 75. Thesystem of claim 73 wherein: the at least one annotation can beinherited.
 76. The system of claim 73 wherein: the at least one inputincludes one of a local interface class, a home interface class, aremote interface class, and a deployment descriptor.
 77. The system ofclaim 73 wherein: the at least one EJB is one of an entity EJB, astateful session EJB, a stateless session EJB, and a message driven EJB.78. The system of claim 77 wherein: an entity EJB includes at least oneof the following relationships: one-to-one, one-to-many, many-to-many,unidirectional, and bi-directional.
 79. The system of claim 73 wherein:the at least one annotation includes at least one attribute.
 80. Thesystem of claim 79 wherein: the at least one attribute is associatedwith at least one expression.
 81. The system of claim 75 wherein:annotation inheritance is based on Java class inheritance.
 82. Thesystem of claim 73 wherein: the annotation is one of a class annotationand a method annotation.
 83. The system of claim 73 wherein: theannotation is a Javadoc tag.
 84. A machine readable medium havinginstructions stored thereon that when executed by a processor cause asystem to: generate at least one output based on a description of atleast one Enterprise Java Bean (EJB), wherein the description isattended by at least one annotation and the at least one annotationincludes at least one variable. 85 The machine readable medium of claim84 wherein: the at least one annotation can be inherited.
 86. Themachine readable medium of claim 84 wherein: the at least one outputincludes one of a local interface class, a home interface class, aremote interface class, and a deployment descriptor.
 87. The machinereadable medium of claim 84 wherein: the at least one EJB is one of anentity EJB, a stateful session EJB, a stateless session EJB, and amessage driven EJB.
 88. The machine readable medium of claim 87 wherein:an entity EJB includes at least one of the following relationships:one-to-one, one-to-many, many-to-many, unidirectional, andbi-directional.
 89. The machine readable medium of claim 84 wherein: theat least one annotation includes at least one attribute.
 90. The machinereadable medium of claim 89 wherein: the at least one attribute isassociated with at least one expression.
 91. The machine readable mediumof claim 85 wherein: annotation inheritance is based on Java classinheritance.
 92. The machine readable medium of claim 84 wherein: the atleast one variable is one of user-specified and predefined.
 93. Themachine readable medium of claim 92 wherein: the at least one predefinedvariable can be redefined.
 94. The machine readable medium of claim 92wherein: the at least one predefined variable can be prefixed with aclass name.
 95. The machine readable medium of claim 84 wherein: theannotation is one of a class annotation and a method annotation.
 96. Themachine readable medium of claim 84 wherein: the annotation is a Javadoctag.
 97. The machine readable medium of claim 84 wherein: the at leastone variable can be defined separately from the description of the atleast one EJB.
 98. The machine readable medium of claim 84 wherein: theat least one output can be used to generate the description of the atleast one EJB.